<?php
namespace Mobile\Controller;
use Think\Controller;
class LoginController extends Controller {


    public function index(){

    	echo "ok";
    }

    public function dologin()
    {
        # code...
        $username = I('username','');
        $password = I('password','');

        $members_model = M("Members");

        // $rules = array(
        //         //array(验证字段,验证规则,错误提示,验证条件,附加规则,验证时间)
        //         array('username', 'require', '用户名不能为空！', 1 ),
        //         array('password','require','密码不能为空！',1),
        // );
        // if($users_model->validate($rules)->create()===false){
        //     $this->ajaxReturn(array('status' => 2, 'info' => $users_model->getError(), 'data' => null));
        //     return;
        // }

        $member_info = $members_model->where(array('member_login_name' => $username))->find();
        if($member_info != null){
            if($member_info['member_password'] == md5($password)){
                $this->ajaxReturn(array('status' => 1, 'info' => '登陆成功', 'data' => array('real_name'=>$member_info['member_real_name'])));
            }else{
                $this->ajaxReturn(array('status' => 0, 'info' => '密码错误', 'data' => null));
            }
        }else{
            $this->ajaxReturn(array('status' => -1, 'info' => '用户不存在', 'data' => null));
        }

    }
}